package com.hice.demo.sbdbra.service.impl;

import com.alibaba.dubbo.config.annotation.Service;
import com.hice.demo.sbdbra.dao.UserDao;
import com.hice.demo.sbdbra.model.User;
import com.hice.demo.sbdbra.service.UserService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 * 用户注册登录信息类
 *
 * @author hyson
 * @create 2017-02-21 17:55
 */
@Component
@Service(version = "1.0.0")
public class UserServiceImpl implements UserService {
    private static final Logger log = LoggerFactory.getLogger(UserServiceImpl.class);
    @Autowired
    UserDao memberDao;

    @Override
    public boolean register(User member) {
        //自动生成sql
        //插入paras到paras对象关联的表,并且指定是否自动将数据库主键赋值到paras里
        memberDao.insert(member, true);
        log.info("dao.insertPK:" + member.toString());
        return member.getId() > 0 ? true : false;
    }

    @Override
    public boolean login(User member) {
        return memberDao.template(member) != null ? true : false;
    }
}
